package com.drawu.drawuspring.controller;


import com.drawu.drawuspring.domain.DTO.GamePageDto;
import com.drawu.drawuspring.domain.Result;
import com.drawu.drawuspring.domain.po.GameComments;
import com.drawu.drawuspring.domain.po.GameInfo;
import com.drawu.drawuspring.service.IGameInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hui
 * @since 2024-11-26
 */
@RestController
@RequestMapping("/game")
@Tag(name = "游戏信息", description = "游戏相关信息")
@RequiredArgsConstructor
public class GameInfoController {
    private final IGameInfoService gameInfoService;

    @Operation(summary = "获取所有捉友信息", description = "获取所有捉友相关信息")
    @GetMapping("/page")
    public Result getGameInfo(GamePageDto gamePageDto) {
        return gameInfoService.getGameInfo(gamePageDto);
    }
    @Operation(summary = "根据id获取捉友信息", description = "根据id获取捉友相关信息")
    @GetMapping("/{id}")
    public Result getGameInfoById(@PathVariable("id") Integer id) {
        return gameInfoService.getGameInfoById(id);
    }

    @Operation(summary = "添加捉友信息", description = "添加捉友相关信息")
    @PostMapping("/add")
    public Result addGameInfo(@RequestBody GameInfo gameInfo) {
        return gameInfoService.addGameInfo(gameInfo);
    }
    @Operation(summary = "根据id删除捉友信息", description = "根据id删除捉友相关信息")
    @DeleteMapping("/delete")
    public Result deleteGameInfo(@RequestParam("id") Integer id) {
        return gameInfoService.deleteGameInfo(id);
    }

    @Operation(summary = "根据id更新捉友信息", description = "根据id更新捉友相关信息")
    @PostMapping("/update")
    public Result updateGameInfo(@RequestBody GameInfo gameInfo) {
        return gameInfoService.updateGameInfo(gameInfo);
    }

    @Operation(summary = "添加评论", description = "添加评论")
    @PostMapping("/addComment")
    public Result addComment(@RequestBody GameComments comment) {
        return gameInfoService.addComment( comment);
    }

    @Operation(summary = "用户模块添加捉友")
    @GetMapping("/addUserGame")
    public Result addUserGame( @RequestParam("gameId") Integer gameId) {
        return gameInfoService.addUserGame(gameId);
    }
    @Operation(summary = "用户模块查询当前用户获得的捉友")
    @GetMapping("/getUserGame")
    public Result getUserGame() {
        return gameInfoService.getUserGame();
    }
}
